package com.book.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.core.domain.Readers;
import com.book.core.query.ReaderQuery;
import com.book.core.vo.PageVO;
import com.book.repository.ReadersMapper;
import com.book.service.ReadersService;
import org.springframework.stereotype.Service;

/**
 * @author hongmizfb
 * @description 针对表【readers(读者信息表)】的数据库操作Service实现
 * @createDate 2025-05-07 22:16:25
 */
@Service
public class ReadersServiceImpl extends ServiceImpl<ReadersMapper, Readers>
        implements ReadersService {
    @Override
    public PageVO<Readers> getReaderPage(ReaderQuery query) {
        String keyword = query.getKeyword();
        Integer status = query.getStatus();
        Integer typeId = query.getTypeId();
        String readerNo = query.getReaderNo();
        Page<Readers> page = lambdaQuery()
                .like(StrUtil.isNotBlank(keyword), Readers::getName, keyword)
                .eq(typeId != null, Readers::getTypeId, typeId)
                .eq(status != null, Readers::getStatus, status)
                .eq(StrUtil.isNotBlank(readerNo), Readers::getReaderNo, readerNo)
                .page(query.toMpPage());
        return PageVO.of(page, Readers.class);
    }
}




